var t = getApp();

Page({
  data: {
    _num: 1,
    show: !0,
    tempFilePaths: [],
    msgSmallUrl: [],
    msgBigUrl: [],
    text: "",
    showw: !0,
    showw1: !1,
    oldHeight: 400,
    height: 400,
    data_arr: [],
  },
  bindlinechange: function (t) {
    var a = this,
      e = this.data.oldHeight;
    this.data.height;
    t.detail.heightRpx > e ? a.setData({
      height: t.detail.heightRpx
    }) : a.setData({
      height: e
    });
  },
  menuClick: function (t) {
    // console.log(t.target.dataset.num), this.setData({
    //     _num: t.target.dataset.num
    // });
    let that = this;
    that.setData({
      titles: t.detail.value
    })
    console.log('我是标题' + that.data.titles)
  },
  Schu: function (t) {
    var a = this,
      e = t.currentTarget.dataset.text,
      o = a.data.tempFilePaths;
    console.log(o.length), o.splice(e, 1), a.setData({
      tempFilePaths: o
    }), o.length < 9 && a.setData({
      show: !0
    });
  },
  pngJia: function (t) {
    var a = this,
      e = a.data.tempFilePaths;
    wx.chooseImage({
      count: 9,
      sizeType: ["original", "compressed"],
      sourceType: ["album", "camera"],
      success: function (t) {
        for (var o = 0; o < t.tempFilePaths.length && (e.push(t.tempFilePaths[o]), !(e.length >= 9)); o++);
        a.setData({
          tempFilePaths: e
        }), e.length >= 9 && a.setData({
          show: !1
        });
      }
    });
  },
  onLoad: function (a) {
    var e = this;
    var uniacid = t.siteInfo.uniacid;
    var zid = a.zid;
    let fname = a.fname;
    let fxid = a.fxid;
    e.setData({
      type: fname,
      fxid: fxid,
      zid: zid
    })
    t.util.request({
      'url': 'entry/wxapp/url',
      'cachetime': '0',
      success: function (res) {
        console.log(res)
        e.setData({
          url: res.data
        })
      },
    })
    e.setData({
      showw: !0,
      showw1: !1,
      uniacid: uniacid
    })
  },
  bindTextAreaBlur: function (t) {
    this.setData({
      text: t.detail.value
    });
  },
  present: function (a) {
    var that = this;
    var sharepic = that.data.tempFilePaths
    var data_arr = that.data.data_arr
    var sharetitle = that.data.titles
    var sharetext = that.data.text
    var zid = that.data.zid
    console.log(zid);
    var ksid = that.data.ksid
    var fxid = that.data.fxid
    //发布后获得积分
    var uniacid = that.data.uniacid
    for (var i = 0; i < sharepic.length; i++) {
      wx.uploadFile({
        url: that.data.url + 'app/index.php?i=' + uniacid + '&c=entry&a=wxapp&do=Upload&m=hyb_yl',
        filePath: sharepic[i],
        name: 'upfile',
        formData: {},
        success: function (res) {
          console.log(res)
          data_arr.push(res.data)
          that.setData({
            data_arr: data_arr
          })
        }
      })
    }
    wx.showToast({
      title: "发布中请稍后......",
      icon: "none",
      duration: 2e3
    });
    setTimeout(function () {
      var data_arr = that.data.data_arr
      console.log(data_arr)
      t.util.request({
        'url': 'entry/wxapp/Fabushare',
        data: {
          sharetitle: sharetitle,
          sharetext: sharetext,
          data_arr: data_arr,
          zid: zid,
          op: 'post',
          fxid: fxid
        },
        success: function (res) {
          console.log(res)
          var pages = getCurrentPages();
          var prevPage = pages[pages.length - 2];
          prevPage.setData({
            type: 1,
            fxid: that.data.fxid
          })

          wx.showToast({
            title: "发布成功",
            icon: "none",
            duration: 2e3,
            success: function () {
              setTimeout(function () {
                wx.navigateBack({
                  delta: 1
                })
              }, 2000)
            }
          });
        }
      })
    }, 2000)


  },
  consultingImage: function (a, e, o, n) {
    var s = n.data.msgSmallUrl,
      l = n.data.msgBigUrl;
    // wx.uploadFile({
    //   url: t.globalData.dic + "doctor/community/uploadImage",
    //   method: "POST",
    //   header: {
    //     "content-type": "multipart/form-data"
    //   },
    //   filePath: a[e],
    //   name: "file",
    //   formData: {},
    //   success: function(i) {
    //     var d = wx.getStorageSync("log") || "";
    //     console.log(i);
    //     var c = JSON.parse(i.data).data;
    //     console.log(c), "" == s ? (s = c.smallFilePath, l = c.bigFilepath) : (console.log(),
    //       s += "|" + c.smallFilePath, l += "|" + c.bigFilepath), n.setData({
    //       msgSmallUrl: s,
    //       msgBigUrl: l
    //     }), ++e == o ? wx.request({
    //       url: t.globalData.dic + "doctor/community/save",
    //       method: "POST",
    //       header: {
    //         "Content-Type": "application/x-www-form-urlencoded"
    //       },
    //       data: {
    //         token: d,
    //         tsid: n.data._num,
    //         tcontentImgBig: n.data.msgBigUrl,
    //         tcontentImgSmll: n.data.msgSmallUrl,
    //         tcontentText: n.data.text
    //       },
    //       success: function(t) {
    //         console.log(t.data.code), wx.hideLoading(), 200 == t.data.code && (wx.setStorageSync("xxx", 0),
    //           wx.switchTab({
    //             url: "/pages/advisory/advisory"
    //           }), null == t.data.data ? wx.showToast({
    //             title: "今日发帖获得积分到达上限",
    //             icon: "none",
    //             duration: 3e3
    //           }) : wx.showToast({
    //             title: "发布成功，恭喜你获得" + t.data.data.getIntegral + "积分",
    //             icon: "none",
    //             duration: 3e3
    //           }));
    //       }
    //     }) : n.consultingImage(a, e, o, n);
    //   }
    // });
  },
  //查询专家科室

});